package com.homer.android.sdk.log;

import org.apache.log4j.Level;

import com.homer.android.sdk.util.EspStrings;
import com.homer.iot.esptouch.base.application.EspApplication;

import android.content.Context;
import android.content.SharedPreferences;



public class ConfigureLog4J
{
    
    public static void configure()
    {
        final LogConfigurator logConfigurator = new LogConfigurator();
        
        SharedPreferences shared =
            EspApplication.sharedInstance().getSharedPreferences(EspStrings.Key.SETTINGS_NAME, Context.MODE_PRIVATE);
        logConfigurator.setUseFileAppender(shared.getBoolean(EspStrings.Key.SETTINGS_KEY_STORE_LOG, false));
        
        logConfigurator.setFileName(LogConfigurator.DefaultLogFileDirPath + LogConfigurator.DefaultLogFileName);
        // Set the root log level
        logConfigurator.setRootLevel(Level.ERROR);
        // Set log level of a specific logger
        logConfigurator.setLevel("org.apache", Level.ERROR);
        logConfigurator.configure();
    }
}
